package com.swedne.test;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.RequiresApi;

import com.swedne.MyService;
import com.swedne.test.dnake.dmsg;
import com.swedne.test.dnake.dxml;

public class MyReciver extends BroadcastReceiver {


    @RequiresApi(api = Build.VERSION_CODES.O)
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        Log.i("zrzTest", action);
        if (TextUtils.isEmpty(action)) {
            return;
        }
        if ("android.intent.action.BOOT_COMPLETED".equals(action) || "com.dnake.broadcast2".equals(action)) {
            Toast.makeText(context, "receiver BOOT_COMPLETED broadcast", Toast.LENGTH_LONG).show();
//            dmsg dmsg = new dmsg();
//            dxml dxml = new dxml();
//            dxml.setText("/params/cmd", "am startservice -n com.swedne.test/.MyService");
//            dmsg.to("/upgrade/root/cmd", dxml.toString());
            context.startForegroundService(new Intent(context, MyService.class));
        }
    }
}
